<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <script>
        // var name = 'andy'
        // var hello = function () {
        //     console.log(this.name)
        //     // console.log(this)
        // }
        // var demo = {
        //     name: 'demo'
        // }
        // var change_value = hello.bind(demo)
        // change_value()


        var fly = function () {
            console.log(`I am a ${this.name}, I can fly`)
        }
        var bird = {
            name: 'bird'
        }
        var plane = {
            name: 'plane'
        }
        // 实际运用案例:可以通过bind实现一些共有方法
        var a = fly.bind(bird)
        a() // I am a bird, I can fly

        var b = fly.bind(plane)
        b() // I am a plane, I can fly
    </script>
</head>

<body>

</body>

</html>